
from game.client.game_data import *
from game.client.model.client_model import *

import pygame
from pygame.locals import *
from OpenGL.GL import *

class ClientMain:

    def __init__(self):
        self.SCREEN_SIZE = (800, 600)
        self.screen = pygame.display.set_mode(self.SCREEN_SIZE, HWSURFACE|OPENGL|DOUBLEBUF) #|DOUBLEBUF TODO: add back... causes vsync
        self.data = GameData(self.SCREEN_SIZE)
        self.data.state.push_state(self.data, "free")

    def run(self):
        code = 0
        while not code:
            ms = self.data.clock.tick()
            for event in pygame.event.get():
                self.data.state.event(self.data, event, ms)
            code = self.data.state.update(self.data, ms)
            self.data.state.draw(self.data)
            pygame.display.flip()

        print code